package com.sxt.springcloud.bus.fallback;

import com.sxt.bus.vo.ProviderVo;
import com.sxt.springcloud.bus.ProviderClientService;
import com.sxt.sys.common.DataGridView;
import com.sxt.sys.common.ResultObj;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProviderClientFallbackService implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new ProviderClientService(){

            /**
             * 查询
             *
             * @param providerVo
             */
            @Override
            public DataGridView loadAllProvider(ProviderVo providerVo) {
                return new DataGridView("服务降级，服务器忙，请稍后重试！调用查询所有供应商方法失败");
            }

            /**
             * 添加
             *
             * @param providerVo
             */
            @Override
            public ResultObj addProvider(ProviderVo providerVo) {
                return ResultObj.SERVER_BUSY;
            }

            /**
             * 修改
             *
             * @param providerVo
             */
            @Override
            public ResultObj updateProvider(ProviderVo providerVo) {
                return ResultObj.SERVER_BUSY;
            }

            /**
             * 删除
             *
             * @param id
             */
            @Override
            public ResultObj deleteProvider(Integer id) {
                return ResultObj.SERVER_BUSY;
            }

            /**
             * 批量删除
             *
             * @param providerVo
             */
            @Override
            public ResultObj batchDeleteProvider(ProviderVo providerVo) {
                return ResultObj.SERVER_BUSY;
            }

            /**
             * 加载所有可用的供应商
             */
            @Override
            public DataGridView loadAllProviderForSelect() {
                return new DataGridView("服务降级，服务器忙，请稍后重试！调用加载所有可用的供应商方法失败");
            }
        };
    }
}
